package com.fan.analysis.module.show.controller;


import com.fan.analysis.common.constant.ResponseCodeConst;
import com.fan.analysis.common.domain.ResponseDTO;
import com.fan.analysis.module.analysis.group.domain.entity.UserInfoEntity;
import com.fan.analysis.module.analysis.group.domain.entity.UserRelationEntity;
import com.fan.analysis.module.show.domain.dto.CallRecordDto;
import com.fan.analysis.module.show.domain.dto.MessageRecordDto;
import com.fan.analysis.module.show.domain.vo.CallRecordVo;
import com.fan.analysis.module.show.domain.vo.MessageVo;
import com.fan.analysis.module.show.service.ShowService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * 用户行为预警
 *
 * @author fan
 * @date 2021/10/08 16:30
 **/
@Slf4j
@RestController
public class ShowController {

    private final ShowService showService;

    @Autowired
    public ShowController(ShowService showService) {
        this.showService = showService;
    }

    @ApiOperation("数据展示-通话记录查询 @author fan")
    @PostMapping(value = "/show/get_call_record_complete")
    public ResponseDTO<List<CallRecordVo>> getCallRecordComplete(@RequestBody @Valid CallRecordDto callRecordDto) {

        log.info("数据展示-通话记录查询");
        try {
            log.info(callRecordDto.toString());
            return showService.getCallRecordComplete(callRecordDto);
        } catch (Exception exception) {
            log.info(exception.getMessage());
            return ResponseDTO.wrap(ResponseCodeConst.SYSTEM_ERROR);
        }
    }

    @ApiOperation("数据展示-短信记录查询 @author fan")
    @PostMapping(value = "/show/get_message_record_complete")
    public ResponseDTO<List<MessageVo>> getMessageRecordComplete(@RequestBody @Valid MessageRecordDto messageRecordDto) {

        log.info("数据展示-短信记录查询");
        try {
            log.info(messageRecordDto.toString());
            return showService.getMessageRecordComplete(messageRecordDto);
        } catch (Exception exception) {
            log.info(exception.getMessage());
            return ResponseDTO.wrap(ResponseCodeConst.SYSTEM_ERROR);
        }
    }

    @ApiOperation("数据展示-获取所有用户关系的方法 @author fan")
    @PostMapping(value = "/show/get_all_user_relation_info")
    public ResponseDTO<List<UserRelationEntity>> getAllUserRelationInfo() {

        log.info("数据展示-获取所有用户关系的方法");
        try {

            return showService.getAllUserRelationInfo();
        } catch (Exception exception) {
            log.info(exception.getMessage());
            return ResponseDTO.wrap(ResponseCodeConst.SYSTEM_ERROR);
        }
    }

    @ApiOperation("数据展示-获取所有用户信息的方法 @author fan")
    @PostMapping(value = "/show/get_all_user_info")
    public ResponseDTO<List<UserInfoEntity>> getAllUserInfo() {

        log.info("数据展示-获取所有用户信息的方法");
        try {

            return showService.getAllUserInfo();
        } catch (Exception exception) {
            log.info(exception.getMessage());
            return ResponseDTO.wrap(ResponseCodeConst.SYSTEM_ERROR);
        }
    }


}
